package com.sunbim.rsrv.controller.v1;


import cn.dev33.satoken.annotation.SaCheckRole;
import com.sunbim.rsrv.service.RegionService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 江苏省地区表 前端控制器
 * </p>
 *
 * @author yuhui
 * @since 2022-02-14
 */
@Api(tags = "地区")
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/region")
public class RegionController {

    @Autowired
    RegionService regionService;

    @GetMapping("getCity")
    public List<Object> getCity() {
        return regionService.getCity();
    }

    @GetMapping("getCityList")
    public List<Object> getCityList() {
        return regionService.getCityList();
    }

    @GetMapping("getZone")
    public List<Object> getZone(
            @RequestParam(value = "city") String city
    ) {
        return regionService.getZone(city);
    }

    @GetMapping("getTown")
    public List<Object> getTown(
            @RequestParam(value = "city") String city,
            @RequestParam(value = "zone") String zone
    ) {
        return regionService.getTown(city, zone);
    }

    @SaCheckRole("admin")
    @GetMapping("getRegionList")
    public List<Object> getRegionList(@RequestParam(value = "user_id") Integer userId) {
        return regionService.getRegionList(userId);
    }
}

